package logic

import (
	"context"
	"ewaimai/waimairpc/waimairpc"

	"ewaimai/api/internal/svc"
	"ewaimai/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PinglunAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPinglunAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PinglunAddLogic {
	return &PinglunAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PinglunAddLogic) PinglunAdd(req *types.PinglunAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.WaimaiRpc.PinglunAdd(l.ctx, &waimairpc.PinglunAddRequest{
		Context:    req.Context,
		Start:      float32(req.Start),
		Image:      req.Image,
		Shoppeople: req.Shoppeople,
		Qishou:     req.Qishou,
		Status:     req.Status,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "评价添加成功",
		Code:    200,
		Data:    add,
	}, nil

}
